package agendaSystem;

/**
 * A class for the creation of personal entries based on the day, description and number of slots.
 * 
 * @invar	The description of each entry must be a valid description for an entry. 
 * 			| isValidDecription(getDescription())
 * @invar	The day of each entry must be a valid day for an entry.
 * 			| isValidDay(getDay())
 * @invar	The slot must be a valid slot for an entry
 * 			| isValidSlot(getSlots()) 
 * 
 * @author	Sabrina Knapen, Axel Vranken
 * @version 1.0 
 * 
 */
public class PersonalEntry extends SlottedEntry {
	
	/**
	 * Initialize a new PersonalEntry with a given description, day, number of agendas and number of slots.
	 * 
	 * @param	description
	 * 			The description of the new entry
	 * @param	day
	 * 			The day of the new entry
	 * @param	agendas
	 * 			The agendas that shall contain the new entry
	 * @pre		The description must be valid for the new entry. 
	 * 			| isValidDescription(description)
	 * @pre		The given day must be a valid day for the new entry. 
	 * 			| isValidDay(day)
	 * @pre		The given agendas must exist. 
	 * 			| for each ag in agendas
	 * 			| 		ag.isTerminated = false
	 * @post	The description of this new entry is equal to the given
	 * 			description. 
	 * 			| new.getDescription() == description
	 * @post	The day of this new entry is equal to the given day. 
	 * 			| new.getDay() == day
	 * @effect	The slots of this new entry will be added to the list of slots. 
	 * 			| for each slot in slots
	 * 			| 		addSlot(slots)
	 * @post	The agendas of this new entry is the same as the
	 *          given agendas.
	 *       	| for each ag in agendas
	 *       	|		new.getAgenda().contains(ag)
	 * @post	The given agendas have this new entry as one of the
	 *         	entries on the given day.
	 *         	| for each ag in agendas
	 *       	| 		ag.getEntriesAt(day).contains(this)
	 * @post    The number of entries for the given agendas on the given day is
	 *          incremented by 1.
	 *          | for each ag in agendas
	 *       	| 		ag.getAllEntries() == ag.getAllEntries() + 1
	 * @effect	The entry belongs to an array of agendas.
	 * 			| for each ag in agendas
	 * 			| 		ag.addEntry(this)
	 * @effect	The agendas are added to the list of agendas for this entry.
	 * 			| for each ag in agenda
	 * 			| 		this.addAgenda(ag)
	 * @throws	IllegalArgumentException	
	 * 		  	The personal entry can only be planned in one agenda.
	 * 		  	| (agendas.length=1)
	 * 
	 */
	public PersonalEntry (Agenda[] agendas, String description, int day,
			int... slots)throws IllegalArgumentException {
		super(agendas,description, day, slots);
		if(agendas.length >1)
			throw new IllegalArgumentException("The entry can only be registered in one agenda.");
	}

	/**
	 * Checks whether the given slot is a valid slot for an entry.
	 * 
	 * @param	slot
	 * 			The slot that needs to be checked.
	 * @return	True if and only if the given slot is not smaller than 1 and not bigger than the maximum number of slots.
	 * 			|result != (slot < 1) && (slot > getMaxSlot())
	 */
	@Override
	public boolean isValidSlot(int slot){
		if(!super.isValidSlot(slot))
			return false;
		else
			return true;		
	}
	
}
